package com.liuhengjia.aiknowledgebase.api;

import com.liuhengjia.aiknowledgebase.common.RestResult;
import com.liuhengjia.aiknowledgebase.service.DocService;
import com.liuhengjia.aiknowledgebase.api.response.DocVO;

import java.util.List;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文档接口
 */
@RestController
@RequestMapping("/api/doc")
@RequiredArgsConstructor
public class DocAPI {
    private final DocService docService;

    /**
     * 文档列表
     *
     * @return 文档 VO 对象
     */
    @GetMapping("/list")
    public RestResult<List<DocVO>> list() {
        return RestResult.buildSuccessResult(docService.list());
    }

    /**
     * 加载/同步 文档
     *
     * @return 操作结果
     */
    @GetMapping("/load")
    public RestResult<String> load() {
        docService.loadData();
        return RestResult.buildSuccessResult();
    }

}
